package com.wuxing.model;

import java.math.BigDecimal;

import com.baomidou.mybatisplus.annotation.*;

import java.time.LocalDateTime;

import java.io.Serializable;

import com.fhs.core.trans.anno.Trans;
import com.fhs.core.trans.constant.TransType;
import com.fhs.core.trans.vo.TransPojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 电商-订单表
 * </p>
 *
 * @author
 * @since 2023-05-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("`order`")
@ApiModel(value = "OrderDO对象", description = "电商-订单表")
public class OrderDO implements TransPojo {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    @ApiModelProperty(value = "重要")
    @Trans(type = TransType.SIMPLE, target = com.wuxing.model.SystemUsersDO.class, fields = "username")
    private Long memberId;

    @ApiModelProperty(value = "优惠券ids 重要")
    private Long couponId;

    @ApiModelProperty(value = "订单编号 重要")
    private String orderSn;

    @ApiModelProperty(value = "提交时间")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "用户帐号")
    private String memberUsername;

    @ApiModelProperty(value = "订单总金额")
    private BigDecimal totalAmount;

    @ApiModelProperty(value = "应付金额（实际支付金额）")
    private BigDecimal payAmount;

    @ApiModelProperty(value = "运费金额")
    private BigDecimal freightAmount;

    @ApiModelProperty(value = "促销优化金额（促销价、满减、阶梯价）")
    private BigDecimal promotionAmount;

    @ApiModelProperty(value = "积分抵扣金额")
    private BigDecimal integrationAmount;

    @ApiModelProperty(value = "优惠券抵扣金额")
    private BigDecimal couponAmount;

    @ApiModelProperty(value = "管理员后台调整订单使用的折扣金额")
    private BigDecimal discountAmount;

    @ApiModelProperty(value = "支付方式：0->未支付；1->支付宝；2->微信")
    private Integer payType;

    @Trans(type = TransType.ENUM, key = "payType")
    @TableField(exist = false)
    private String payTypeName;

    public String getPayTypeName() {
        if(payType != null) {
            return PayType.getEnum(payType).getDesc();
        }
        return null;
    }
    public enum PayType {
        NOPAY(0,"未支付"),
        ALIPAY(1,"支付宝"),
        WECHAT(2,"微信");
        private Integer payType;
        private String desc;
        PayType(Integer payType ,String desc) {
            this.payType = payType;
            this.desc = desc;
        }
        public String getDesc() {
            return desc;
        }
        public static PayType getEnum(Integer type) {
            PayType value = null;
            for(PayType temp : PayType.values()) {
                if(type.equals(temp.payType)) {
                    value = temp;
                    break;
                }
            }
            return value;
        }
    }

    @ApiModelProperty(value = "订单来源：0->PC订单；1->app订单")
    private Integer sourceType;
    @Trans(type = TransType.ENUM, key = "sourceType")
    @TableField(exist = false)
    private String sourceTypeName;
    public String getSourceTypeName() {
        if(sourceType != null) {
            return SourceType.getEnum(sourceType).getDesc();
        }
        return null;
    }
    public enum SourceType {
        PC(0,"PC订单"),
        APP(1,"app订单");

        private Integer payType;
        private String desc;
        SourceType(Integer payType ,String desc) {
            this.payType = payType;
            this.desc = desc;
        }
        public String getDesc() {
            return desc;
        }
        public static SourceType getEnum(Integer type) {
            SourceType value = null;
            for(SourceType temp : SourceType.values()) {
                if(type.equals(temp.payType)) {
                    value = temp;
                    break;
                }
            }
            return value;
        }
    }


    @ApiModelProperty(value = "订单状态：0->待付款；1->待发货；2->已发货；3->已完成；4->已关闭；5->无效订单")
    private Integer yesapiMallOmsOrderStatus;

    @ApiModelProperty(value = "订单类型：0->正常订单；1->秒杀订单")
    private Integer orderType;

    @ApiModelProperty(value = "物流公司(配送方式)")
    private String deliveryCompany;

    @ApiModelProperty(value = "物流单号")
    private String deliverySn;

    @ApiModelProperty(value = "自动确认时间（天）")
    private Integer autoConfirmDay;

    @ApiModelProperty(value = "可以获得的积分")
    private Integer integration;

    @ApiModelProperty(value = "可以活动的成长值")
    private Integer growth;

    @ApiModelProperty(value = "活动信息")
    private String promotionInfo;

    @ApiModelProperty(value = "发票类型：0->不开发票；1->电子发票；2->纸质发票")
    private Integer billType;

    @ApiModelProperty(value = "发票抬头")
    private String billHeader;

    @ApiModelProperty(value = "发票内容")
    private String billContent;

    @ApiModelProperty(value = "收票人电话")
    private String billReceiverPhone;

    @ApiModelProperty(value = "收票人邮箱")
    private String billReceiverEmail;

    @ApiModelProperty(value = "收货人姓名")
    private String receiverName;

    @ApiModelProperty(value = "收货人电话")
    private String receiverPhone;

    @ApiModelProperty(value = "收货人邮编")
    private String receiverPostCode;

    @ApiModelProperty(value = "省份/直辖市")
    private String receiverProvince;

    @ApiModelProperty(value = "城市")
    private String receiverCity;

    @ApiModelProperty(value = "区")
    private String receiverRegion;

    @ApiModelProperty(value = "详细地址")
    private String receiverDetailAddress;

    @ApiModelProperty(value = "订单备注")
    private String note;

    @ApiModelProperty(value = "确认收货状态：0->未确认；1->已确认")
    private Integer confirmStatus;

    @ApiModelProperty(value = "删除状态：0->未删除；1->已删除")
    private Integer deleteStatus;

    @ApiModelProperty(value = "下单时使用的积分")
    private Integer useIntegration;

    @ApiModelProperty(value = "支付时间")
    private LocalDateTime paymentTime;

    @ApiModelProperty(value = "发货时间")
    private LocalDateTime deliveryTime;

    @ApiModelProperty(value = "确认收货时间")
    private LocalDateTime receiveTime;

    @ApiModelProperty(value = "评价时间")
    private LocalDateTime commentTime;

    @ApiModelProperty(value = "修改时间")
    private LocalDateTime modifyTime;


}
